dynamic class com.c3d.mediaRotator.data.Model extends Object
{
    var _feedSrc: String = "";
    var _feedType: String = "";
    var _rawFeedReturnString: String = "";
    var _parsedFeedReturnObject = null;
    var _bannerGlobalConfig;
    var _bannerTransitionConfig;
    var _controller;
    var _internalRequestID;
    var _runtimeConfigInfo;

    function Model()
    {
        super();
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.MVCEvent.MODEL_INSTANTIATED, target: this});
    }

    function initialize($fetchImmediately)
    {
        if ($fetchImmediately) 
        {
            this.fetchData();
        }
    }

    function fetchData()
    {
        if (this._feedSrc == "") 
        {
            this._feedSrc = "newdata.xml";
        }
        if (this._feedType == "") 
        {
            this._feedType = "xml";
        }
        com.c3d.common.events.CentralDispatch.addEventListener(com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_COMPLETE, mx.utils.Delegate.create(this, this.onFetchDataComplete));
        this._internalRequestID = this._controller.requestNetworkData(this._feedSrc, this._feedType);
    }

    function onFetchDataComplete($event)
    {
        if ($event.uid == this._internalRequestID) 
        {
            this.parseData($event.data);
            return;
        }
    }

    function parseData($rawData)
    {
        this._runtimeConfigInfo = $rawData;
        this._bannerGlobalConfig = new Object({stageCornerRadius: new Array(5, 5, 5, 5), stageSize: new flash.geom.Point(200, 200), stageColor: 200, stageMarginSize: new flash.geom.Point(0, 0), stageMarginFillColor: 16777215, stageMarginStrokeColor: 3355443, stageMarginStrokeWidth: 1, transitionCountdownPos: new flash.geom.Point(-500, -500)});
        var __reg6 = new Object({color: 16777215, width: 120, height: 60, cornerradius: new Array(5, 5, 0, 0), dimcolor: 3355443, dimlinercolor: 3355443, dimalpha: 0.5, labelcolor: 0, labelsize: 12, labeldimalpha: 0.5});
        this._bannerTransitionConfig = new Object({transitionDuration: 0.5, mouseMoveTimeout: 2000});
        var __reg2 = this._runtimeConfigInfo.Banner.attributes;
        if (__reg2.bannerCornerRadius) 
        {
            var __reg5 = __reg2.bannerCornerRadius.split(",");
            if (__reg5.length > 1) 
            {
                var __reg3 = 0;
                while (__reg3 < 4) 
                {
                    if (__reg5[__reg3] && Number(__reg5[__reg3]) == __reg5[__reg3]) 
                    {
                        this._bannerGlobalConfig.stageCornerRadius[__reg3] = Number(__reg5[__reg3]);
                    }
                    else 
                    {
                        this._bannerGlobalConfig.stageCornerRadius[__reg3] = 0;
                    }
                    ++__reg3;
                }
            }
            else if (__reg5[0] == Number(__reg5[0]) && __reg5[0].length > 0) 
            {
                var __reg9 = Number(__reg5[0]);
                this._bannerGlobalConfig.stageCornerRadius = new Array(__reg9, __reg9, __reg9, __reg9);
            }
        }
        if (__reg2.bannerWidth && __reg2.bannerHeight && __reg2.bannerWidth == Number(__reg2.bannerWidth) && __reg2.bannerHeight == Number(__reg2.bannerHeight)) 
        {
            this._bannerGlobalConfig.stageSize = new flash.geom.Point(Number(__reg2.bannerWidth), Number(__reg2.bannerHeight));
        }
        if (__reg2.bannerBackgroundColor) 
        {
            this._bannerGlobalConfig.stageColor = Number(__reg2.bannerBackgroundColor);
        }
        if (__reg2.bannerHorizontalMargin || __reg2.bannerVerticalMargin || __reg2.bannerMargin) 
        {
            if (__reg2.bannerHorizontalMargin && __reg2.bannerVerticalMargin) 
            {
                this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(__reg2.bannerHorizontalMargin, __reg2.bannerVerticalMargin);
            }
            else if (!__reg2.bannerHorizontalMargin && __reg2.bannerVerticalMargin) 
            {
                if (__reg2.bannerMargin) 
                {
                    this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(0, __reg2.bannerVerticalMargin);
                }
                else 
                {
                    this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(__reg2.bannerVerticalMargin, __reg2.bannerVerticalMargin);
                }
            }
            else if (__reg2.bannerHorizontalMargin && !__reg2.bannerVerticalMargin) 
            {
                if (__reg2.bannerMargin) 
                {
                    this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(__reg2.bannerVerticalMargin, 0);
                }
                else 
                {
                    this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(__reg2.bannerHorizontalMargin, __reg2.bannerVerticalMargin);
                }
            }
            else if (__reg2.bannerMargin) 
            {
                this._bannerGlobalConfig.stageMarginSize = new flash.geom.Point(__reg2.bannerMargin, __reg2.bannerMargin);
            }
        }
        if (__reg2.bannerMarginFillColor) 
        {
            this._bannerGlobalConfig.stageMarginFillColor = Number(__reg2.bannerMarginFillColor);
        }
        if (__reg2.bannerMarginStrokeColor) 
        {
            this._bannerGlobalConfig.stageMarginStrokeColor = Number(__reg2.bannerMarginStrokeColor);
        }
        if (__reg2.bannerMarginStrokeWidth) 
        {
            this._bannerGlobalConfig.stageMarginStrokeWidth = Number(__reg2.bannerMarginStrokeWidth);
        }
        var __reg8 = __reg2.transitionCountdownPos.split(",");
        if (__reg8.length == 2) 
        {
            this._bannerGlobalConfig.transitionCountdownPos = new flash.geom.Point(Number(__reg8[0]), Number(__reg8[1]));
        }
        else if (__reg8.length == 1 && Number(__reg8[0]) == __reg8[0]) 
        {
            this._bannerGlobalConfig.transitionCountdownPos = new flash.geom.Point(Number(__reg8[0]), Number(__reg8[0]));
        }
        if (__reg2.tabColor) 
        {
            __reg6.color = Number(__reg2.tabColor);
        }
        if (__reg2.tabWidth) 
        {
            __reg6.width = Number(__reg2.tabWidth);
        }
        if (__reg2.tabHeight) 
        {
            __reg6.height = Number(__reg2.tabHeight);
        }
        if (__reg2.tabCornerRadius) 
        {
            if (__reg2.tabCornerRadius.indexOf(",") == -1) 
            {
                if (__reg2.tabCornerRadius == Number(__reg2.tabCornerRadius)) 
                {
                    __reg9 = Number(__reg2.tabCornerRadius);
                    __reg6.cornerradius = new Array(__reg9, __reg9, __reg9, __reg9);
                }
            }
            else 
            {
                var __reg7 = __reg2.tabCornerRadius.split(",");
                var __reg4 = 0;
                while (__reg4 < 4) 
                {
                    if (__reg7[__reg4]) 
                    {
                        __reg6.cornerradius[__reg4] = Number(__reg7[__reg4]);
                    }
                    else 
                    {
                        __reg6.cornerradius[__reg4] = 0;
                    }
                    ++__reg4;
                }
            }
        }
        if (__reg2.tabDimColor) 
        {
            __reg6.dimcolor = Number(__reg2.tabDimColor);
        }
        if (__reg2.tabDimAlpha) 
        {
            __reg6.dimalpha = Number(__reg2.tabDimAlpha);
        }
        if (__reg2.tabLabelColor) 
        {
            __reg6.labelcolor = Number(__reg2.tabLabelColor);
        }
        if (__reg2.tabLabelSize) 
        {
            __reg6.labelsize = Number(__reg2.tabLabelSize);
        }
        if (__reg2.tabLabelDimAlpha) 
        {
            __reg6.labeldimalpha = Number(__reg2.tabLabelDimAlpha);
        }
        if (__reg2.tabDimLinerColor) 
        {
            __reg6.dimlinercolor = Number(__reg2.tabDimLinerColor);
        }
        this._bannerGlobalConfig.tabConfig = __reg6;
        if (__reg2.transitionSpeed) 
        {
            this._bannerTransitionConfig.transitionDuration = Number(__reg2.transitionSpeed);
        }
        if (__reg2.mouseMoveTimeout) 
        {
            this._bannerTransitionConfig.mouseMoveTimeout = Number(__reg2.mouseMoveTimeout);
        }
        this.onParseDataComplete();
    }

    function onParseDataComplete()
    {
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.MVCEvent.MODEL_READY, target: this});
    }

    function set feedSrc($s)
    {
        this._feedSrc = $s;
    }

    function set feedType($s)
    {
        if ((__reg0 = $s.toLowerCase()) === "xml") 
        {
            this._feedType = "xml";
        }
        else if (__reg0 === "json") 
        {
            this._feedType = "json";
        }
        else 
        {
            this._feedType = "xml";
        }
    }

    function set controller($c)
    {
        this._controller = $c;
    }

    function get panelData()
    {
        var __reg2 = new Array();
        for (var __reg3 in this._runtimeConfigInfo.Banner.item) 
        {
            __reg2.push(this._runtimeConfigInfo.Banner.item[__reg3]);
        }
        return __reg2.concat();
    }

    function get numBasePanels()
    {
        return this._runtimeConfigInfo.Banner.item.length;
    }

    function get globalConfigParams()
    {
        return this._bannerGlobalConfig;
    }

    function get bannerTransitionDuration()
    {
        return this._bannerTransitionConfig.transitionDuration;
    }

    function get mouseMoveTimeout()
    {
        return this._bannerTransitionConfig.mouseMoveTimeout;
    }

}
